<template>
  <div>
    <div
      style="font-size: 16px;font-weight: 500;color: #1D2129;margin-bottom: 16px;"
    >
      校外体育中心人员分布情况
    </div>
    <div
      id="Chart1"
      style="width:100%;height:220px;margin-top:-20px;margin-left:-15px"
    ></div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "SchoolType",
  data() {
    return {
      chartInstance: null
    };
  },
  mounted() {
    this.datalist();
  },

  methods: {
    datalist() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("Chart1"));
      // 指定图表的配置项和数据
      var option;
      option = {
        tooltip: {
          trigger: "axis"
        },
        legend: {
          data: ["Rainfall", "Evaporation"]
        },

        calculable: true,
        xAxis: [
          {
            type: "category",
            // prettier-ignore
            data: ['Jan', 'Feb', 'Mar']
          }
        ],
        yAxis: [
          {
            type: "value"
          }
        ],
        series: [
          {
            name: "Rainfall",
            type: "bar",
            data: [2.0, 4.9, 7.0]
          },
          {
            name: "Evaporation",
            type: "bar",
            data: [2.6, 5.9, 9.0]
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
      // 监听父元素大小变化 刷新图表
      var ro = new ResizeObserver(entries => {
        for (let entry of entries) {
          const cr = entry.contentRect;
          myChart.resize();
        }
      });
      ro.observe(Chart);
    }
  }
};
</script>

<style scoped>
.dianidan {
  width: 7px;
  height: 7px;
  margin-right: 5px;
  margin-top: 3px;
}
</style>
